Spring Boot 成功連 MySQL,可查 effects / foods / evidence
/api/effects 回資料(從 DB 讀)
打好 DAO / RowMapper / Service 骨架
工作項目
- 設定連線
src/main/resources/application.properties
spring.datasource.url=jdbc:mysql://localhost:3306/mymall?useSSL=false&serverTimezone=Asia/Taipei&characterEncoding=utf8
spring.datasource.username=mall
spring.datasource.password=mallpass
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
- 建表與最小測試資料
- db/schema.sql、db/data.sql
- 確保 effects 有 E001/E002;evidence 有基本資料
- DAO & RowMapper
- EffectDao:List<EffectDto> findAll()
- EvidenceDao:List<EvidenceRow> findByEffect(String effectId)
- RowMapper:EffectRowMapper、RecommendationItemRowMapper
- Service
- EffectService.listEffects() 直接呼叫 EffectDao
- RecommendationService.recommend(effectId) 先直接回 evidence 的原始清單(暫不算分)
- Controller
EffectController → GET /api/effects
RecommendationController → GET /api/recommendations?effectId=E001|E002
- 驗收
curl "http://localhost:8080/api/effects":看到 E001/E002
curl "http://localhost:8080/api/recommendations?effectId=E002":至少有清單(尚未排序)